import request from "@/utils/request";

// 在线提交问题
export function submitNewQuestion(data) {
    return request({
        url: '/question/submitQuestion',
        method: 'post',
        data: data
    })
}

// 根据type获取问题列表
export function getQuestionList(type, tag) {
    return request({
        url: `/question/getQuestionList?type=${type}&tag=${tag}`,
        method: 'get'
    })
}

// 获取疾病热度排行榜
export function getDiseaseHotList() {
    return request({
        url: '/question/getDiseaseHotList',
        method: 'get'
    })
}

// 获取权威医生列表
export function getPositiveDoctorList() {
    return request({
        url: '/question/getPositiveDoctorList',
        method: 'get'
    })
}

// 更新阅读量
export function updateView(id) {
    return request({
        url: `/question/clickQuestion?id=${id}`,
        method: 'put'
    })
}

// 提交问题的回复
export function submitReply(data) {
    return request({
        url: '/question/submitAnswer',
        method: 'post',
        data: data
    })
}

// 获取一个问题的全部回复内容
export function getQuestionAllAnswer(id) {
    return request({
        url: `/question/getQuestionAllAnswer?questionId=${id}`,
        method: 'get'
    })
}

// 将一个回答采纳为最佳回答
export function adoptAnswer(id) {
    return request({
        url: `/question/adoptAnswer?answerId=${id}`,
        method: 'put'
    })
}

// 给医生留言
export function leaveMessage(data) {
    return request({
        url: '/question/leaveMessage',
        method: 'post',
        data: data
    })
}

// 获取当前用户所有留言
export function getUserMessage() {
    return request({
        url: '/question/getUserMessage',
        method: 'get'
    })
}

// 回复一条留言
export function replyMessage(data) {
    return request({
        url: '/question/replyMessage',
        method: 'post',
        data: data
    })
}

// 标记一条留言为已读
export function markMessageRead(id) {
    return request({
        url: `/question/hasReadMessage?messageId=${id}`,
        method: 'put'
    })
}